package userInterface;

import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;

import userInterface.MainFrame;

public class HelpDialog extends JDialog{
	
	private static final String wikiString = "http://code.google.com/p/villicuscollaboration/w/list";
	private static final String issueString = "http://code.google.com/p/villicuscollaboration/issues/list";
	
	public HelpDialog() {
		this.setLayout(new FlowLayout());
		JPanel panel1 = new JPanel(new GridLayout(3, 2, 10, 10));
		JButton wikiButton = new JButton("WIKI");
		JLabel wikiLabel = new JLabel("Find Help on the WIKI:");
		JButton issueButton = new JButton("ISSUES");
		JLabel issueLabel = new JLabel("Report an issue:");
		JButton close = new JButton("Close");
		panel1.add(wikiLabel);
		panel1.add(wikiButton);
		panel1.add(issueLabel);
		panel1.add(issueButton);
		panel1.add(Box.createGlue());
		panel1.add(close);
		ActionListener closeDialog = new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				closeDialog();
				
			}
			
		};
		ActionListener goToWiki = new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				BrowserLauncher wikiBrowser = new BrowserLauncher();
				wikiBrowser.openURL(wikiString);
				
			}
			
		};
		ActionListener goToIssues = new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				BrowserLauncher issuesBrowser = new BrowserLauncher();
				issuesBrowser.openURL(issueString);				
			}
			
		};
		wikiButton.addActionListener(goToWiki);
		issueButton.addActionListener(goToIssues);
		close.addActionListener(closeDialog);
		this.add(panel1);
		this.setModal(true);
		this.pack();
		this.setLocationRelativeTo(MainFrame.mainFrame);
		this.setVisible(true);
	}
	
	public void closeDialog() {
		this.setVisible(false);
		this.dispose();
	}

}
